<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>获取微信code</title>
  <link href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.css" rel="stylesheet">
</head>

<body>
  <div id="app">
    <h1> hello 这是获取code页面 ！</h1>
    <h1>your input is {{message}}</h1>
    <input type="text" v-model="message">
  
    
  </div>
  <script>
    angular.module('myApp', [])
      .controller('MyController', function ($scope, $http) {
        (function () {
          var wei = 'https://open.weixin.qq.com/connect/oauth2/authorize?' +
            'wx2750055a558bbe86' +
            '&redirect_uri=' +
            'http://mxr.dounixue.net/' +
            '&response_type=code' +
            '&scope=snsapi_userinfo' +
            '&state=STATE' +
            '#wechat_redirect';
          window.location.href = wei;
        })();

        $scope.getQueryString = function (name) {
          var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
          var r = window.location.search.substr(1).match(reg);
          if (r != null) {
            return unescape(r[2]);
          } else {
            return null;
          }
        };
        var code = $scope.getQueryString('code');
        console.log(code);
        $scope.save = function () {
          $http({
            method: "GET",
            url: '/a/wx/code',
            params: {
              code: code
            }
          }).then(function (response) {
            if (response.data.code === 0) {
              alert("welcome !")
            } else {
              alert(response.data.message);
            }
          });
        };
        $scope.save();
      });

  </script>
  <script>
    var vm = new Vue({
      el: '#app',
      data: {
        message: 'Hello world,i am vue.js!'
      }
    })

  </script>
  <script src="https://cdn.bootcss.com/vue/2.5.16/vue.js"></script>
  <!-- <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <script src="https://cdn.bootcss.com/angular.js/1.6.6/angular.js"></script> -->
  <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
  <script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
</body>

</html>


<!-- 
https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx2750055a558bbe86&redirect_uri=http://dev.zhihui.school.ptteng.com/wxRedirect&response_type=code&**scope=snsapi_userinfo**&state=type%3Dquan%2Curl%3Dhttp%3A%2F%2Fmm.dianping.com%2Fweixin%2Faccount%2Fhome

https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx2750055a558bbe86&redirect_uri=http://mxr.dounixue.net&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect
 -->
<!-- 
 <!DOCTYPE html>
 <html>
     <head>
         <meta http-equiv="content-type" content="text/html;charset=utf-8">
     </head>
     <body>
         <span id="login_container"></span>
         <script src="http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js"></script>
         <script>
             var obj = new WxLogin({
               id: "login_container",
               appid: "wxed782be999f86e0e",
               scope: "snsapi_login",
               redirect_uri: encodeURIComponent("http://" + window.location.host + "/login.php"),
               state: Math.ceil(Math.random()*1000),
               style: "black",
               href: ""});
         </script>
     </body>
 </html> -->
<!-- 

appid=wx2750055a558bbe86;
redirect_uri=http://mxr.dounixue.net/;
response_type=code;
secret=fe33aae20890da44fc14c709468b7a91



https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx2750055a558bbe86&redirect_uri=http://mxr.dounixue.net/&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect

https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx2750055a558bbe86&secret=fe33aae20890da44fc14c709468b7a91&code=081Wf5q51qRloL1Uegs51Xr8q51Wf5qb&grant_type=authorization_code


{
  "access_token": "11_2iCaoC6N70D4gTgKn02N9xYf-KoICgkYrD6FaUF8PBPpceTFx5uEw5ugH-3RduGJEkxDREYLRwuSHGmM-8GlMQ",
  "expires_in": 7200,
  "refresh_token": "11_fBIv2fuxrPDRxYQ7h9Nv3_ebYe3-5tUMeWaORJD7mhntQS95UI73XzeG_23xsWqCDqYcnMpYb2WML0-GiVmCgA",
  "openid": "oSV35t1edoa7ocKrAhuK_bGJZXQc",
  "scope": "snsapi_userinfo"
  }


  https://api.weixin.qq.com/sns/userinfo?access_token=11_2iCaoC6N70D4gTgKn02N9xYf-KoICgkYrD6FaUF8PBPpceTFx5uEw5ugH-3RduGJEkxDREYLRwuSHGmM-8GlMQ&openid=oSV35t1edoa7ocKrAhuK_bGJZXQc&lang=zh_CN -->

<!-- 
  1、用户访问自定义菜单的url..
   https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx2750055a558bbe86&redirect_uri=http://mxr.dounixue.net/&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect
  
  2、微信解析到
    http://mxr.dounixue.net/?code=061lWlgU1CiUYV0Ez6hU1paegU1lWlgx&state=STATE
  我要截取url上的code。向后端发送请求。。他返回给我一个id。。和openid..(这个值就是我请求的code)
  {
    "status": 0,
    "data": {
      "id": 18,
      "openid": "021SFAjY02C6412Z9OfY0VxIjY0SFAj7"
    },
    "msg": "验证成功"
  }

  011a1XzL0hu7q62rEfzL0ImUzL0a1Xz- -->
<!-- 以下是用code通过官方接口返回的json包。 -->
<!-- 
https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx2750055a558bbe86&secret=fe33aae20890da44fc14c709468b7a91&code=071TbCs11sFTBZ1kikt11toGs11TbCsb&grant_type=authorization_code
  {
    "access_token": "11_YNfmJ6NLK6Mm3AW9iDYH2VKlu8bo2pnuBAy77sZgzjyrqE52iI417odqpEzfveZpKwt5uXhc_DLsoSYS7Rgz4Q",
    
    "expires_in": 7200,
    "refresh_token": "11_qtTfdF4t2cpYYfBG3THeOHjB9NGuuB6uBj0O-0UtzP0GhGD0Fhe-MYlxxUO4Bk7Y2lDUX2UI9AufDW8FFGP2vQ",
    "openid": "oSV35t1edoa7ocKrAhuK_bGJZXQc",
    "scope": "snsapi_userinfo"
  }  
  3、我通过code=openid    get请求   
  http：GET（请使用https协议）
  https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=oSV35t1edoa7ocKrAhuK_bGJZXQc=zh_CN -->
  <!-- https://api.weixin.qq.com/sns/userinfo?access_token=11_CrUHO6nKnmbKYW_G3xRbcsyTOzadtxF_HBM7hfEIjtGdG3HHBJl3qK8F6usJgiZbRfrTWX02pX4r2WznpknSWw&openid=oSV35t1edoa7ocKrAhuK_bGJZXQc&lang=zh_CN



  "openid": "oSV35t1edoa7ocKrAhuK_bGJZXQc",
  "webAccessToken": "11_aDux0RGd41BZehuTXMlmZ-nYF3edaZoTaWFhKSUO0hS7ZLmIw3IfLCANG4-YT9TUTUSwdd8CoRl6bjkv7VzsNA" -->